import {createAction} from 'redux-actions';
import httpUtil from '../utils/HttpUtil';
import * as types from '../utils/type/CommonTypes';
import Url from '../utils/Constant';

function getTreeSort() {
    return dispatch => {
        httpUtil.get(Url.WApiTree)
            .then(res => {
                dispatch(createAction(types.FETCH_SORT_DONE)(res.data))
            });
    }
}

function getSortArticle(page,cid) {
    return dispatch => {
        dispatch(createAction(types.FETCH_SORT_ARTICLE_DOING));
        httpUtil.get(Url.WApiTreeArticle0 + page + Url.WApiTreeArticle1+cid)
            .then(res => {
                dispatch(createAction(types.FETCH_SORT_ARTICLE_DONE)(res.data))
            });
    }
}

export {
    getSortArticle,
    getTreeSort
}